package com.xing.controller;

import com.xing.DTO.SysNotificationDTO;
import com.xing.Utils.Result;
import com.xing.service.SysNotificationService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @Author <a href="https://gitee.com/a-tom-is-cry">Xing</a>
 * @Date 2025/3/19 21:08
 * @Description
 */
@Tag(name = "站内消息通知")
@RestController
@RequestMapping(value = "notification")
public class SysNotificationController {

    @Autowired
    private SysNotificationService service;

    @GetMapping("page")
    @Operation(summary = "获取站内消息")
    @Parameters({
            @Parameter(name = "currentPage", description = "页码", required = true),
            @Parameter(name = "pageSize", description = "页内数目", required = true),
            @Parameter(name = "title", description = "按照消息标题查找：like", required = false),
            @Parameter(name = "receivedId", description = "接收人ID:eq", required = false),
            @Parameter(name = "delFlag", description = "根据当前直播状态的关注：eq", required = false),
            @Parameter(name = "createDate", description = "根据创建时间：eq", required = false),
    })
    public Result page(@RequestParam(required = false) Map<String, Object> params) {
        return service.Page(params);
    }


    @PostMapping("sendNotification")
    @Operation(summary = "发送通知")
    public Result sendNotification(@RequestBody SysNotificationDTO dto){
        return service.SendNotification(dto);
    }


    @Operation(summary = "系统通知")
    @PostMapping("sendSystemNotification")
    public Result sendSystemNotification(@RequestBody SysNotificationDTO dto){
        return service.sendSystemNotification(dto);
    }

    @Operation(summary = "消息处理")
    @DeleteMapping("{id}")
    public Result handleNotification(@PathVariable("id") String id){
        return service.handleNotification(id);
    }


}
